package math

import "jvmgo/ch07/instructions/base"
import "jvmgo/ch07/rtda"

// double取反指令
type DNEG struct {
    base.NoOperandsInstruction
}

func (self *DNEG) Execute(frame *rtda.Frame) {
    stack := frame.OperandStack()
    val := stack.PopDouble()
    stack.PushDouble(-val)
}

// float取反指令
type FNEG struct {
    base.NoOperandsInstruction
}

func (self *FNEG) Execute(frame *rtda.Frame) {
    stack := frame.OperandStack()
    val := stack.PopFloat()
    stack.PushFloat(-val)
}

// int取反指令
type INEG struct {
    base.NoOperandsInstruction
}

func (self *INEG) Execute(frame *rtda.Frame) {
    stack := frame.OperandStack()
    val := stack.PopInt()
    stack.PushInt(-val)
}

// long取反指令
type LNEG struct {
    base.NoOperandsInstruction
}

func (self *LNEG) Execute(frame *rtda.Frame) {
    stack := frame.OperandStack()
    val := stack.PopLong()
    stack.PushLong(-val)
}
